﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Fetion.Core
{
    /// <summary>
    /// byte[]引用对象
    /// </summary>
    public class ByteArraySegment
    {
        public ByteArraySegment()
        {
        }
        public ByteArraySegment(int count)
        {
            Array = new byte[count]; 
        }
        /// <summary>
        /// 获取对应的byte[]
        /// </summary>
        public byte[] Array
        {
            get;
            private set;
        }
        /// <summary>
        /// 起始位置
        /// </summary>
        public int Offset;
        /// <summary>
        /// 总长度
        /// </summary>
        public int Count;
        /// <summary>
        /// 设置引用信息
        /// </summary>
        /// <param name="offset">开始位置</param>
        /// <param name="count">长度</param>
        public void SetInfo(int offset, int count)
        {
            Offset = offset;
            Count = count;
        }
        /// <summary>
        /// 设置引用信息
        /// </summary>
        /// <param name="data">byte[]</param>
        /// <param name="offset">起始位置</param>
        /// <param name="count">总长度</param>
        public void SetInfo(byte[] data, int offset, int count)
        {
            Array = data;
            Offset = offset;
            Count = count;
        }
        /// <summary>
        /// 清除资源
        /// </summary>
        public void Clear()
        {
            Array = null;
        }
    }
}
